home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_08_06
/
8n06066a
< prev
next >
Wrap
Text File
|
1989-11-08
|
2KB
|
51 lines
/*
** datetest.c -- test program for DateObjects
*/
#include <stdio.h>
#include <stream.hpp>
#include "dates.hpp"
void main(void)
{
DateObject d1(1, 1, -4700, "d mmmm yyyy");
DateObject d2(31, 12, 25000, "d mmmm yyyy");
DateObject d3(23, 5, 1968, "d mmm yyy");
DateObject d4; /* initialize to todays date */
DateObject d5;
long Diff;
cout << "DateObjects can span dates from " << d1.DateToString() << "\n";
cout << "to " << d2.DateToString() << ", or ";
cout << (Diff = (d2 - d1)) << " days.\n\n";
cout << "A good reference date is " << d3.DateToString() << "\n";
cout << "which should have a Julian date of 2440000.\n";
cout << "If we call GetJulian() to make sure, we find\n";
cout << "that it does";
if (d3.GetJulian() != 2440000L)
cout << " not";
cout << ", in fact, equal 2440000.\n\n";
cout << "Attempting to add " << Diff << " days to " <<
d3.DateToString() << "\n";
cout << "yields a " << (d3 + Diff).DateToString() << ".\n";
cout << "Attempting to subtract " << Diff << " days from " <<
d3.DateToString() << "\n";
cout << "yields a " << (d3 - Diff).DateToString() << ".\n";
cout << "However, adding " << Diff << " days to " <<
d1.DateToString() << "\n";
cout << "yields " << (d1 + Diff).DateToString() << ".\n\n";
cout << "Today is " << d4.DateToString() << ".\n";
d4.ChangeFormat("dddd");
cout << "The next five days are:\n";
for (++d4 ; d4 <= d5 + 5; d4++)
cout << d4.DateToString() << "\n";
cout << "\n";
}